package com.easyboot.web.monitor.jobs;

import com.easyboot.utils.log.LoggerHelper;
import org.quartz.*;
import org.springframework.stereotype.Component;

/**
 * @author yushuo
 * @className
 * @descripton TODO
 * @date 2021/3/2 10:55
 **/

@DisallowConcurrentExecution //作业不并发
@Component("SimpleQuartzJob")
public class SimpleQuartzJob implements Job{

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException{
        JobKey key = jobExecutionContext.getJobDetail().getKey();
        JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        String jobSays = dataMap.getString("easyboot");
        Long jobId=dataMap.getLong("jobId");
        LoggerHelper.console("Instance："+key+"；jobSays:"+ jobSays+" jobId:"+jobId);
        //LoggerHelper.console("this job from quartz:"+ DateUtil.now());
        try {
            Thread.sleep(5*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //LoggerHelper.console("this job end from quartz:"+ DateUtil.now());
    }

//    @Override
//    public void doExecute(JobExecutionContext context) throws Exception
//    {
//        JobKey key = context.getJobDetail().getKey();
//        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
//        String jobSays = dataMap.getString("easyboot");
//        String jobId=dataMap.getString("jobId");
//
//        LoggerHelper.console("Instance："+key+"；jobSays:"+ jobSays);
//        try {
//            Thread.sleep(5*1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//    }
}
